<?php

// $Id$


class TCMS_Menu_Item extends Tangra_Class {
	private $id;
	private $menu;
	private $parent = 0;
	private $label;
	private $published;
	private $ordering = 10;
	private $type;
	private $nofollow;
	private $new_window = 0;
	private $additional;
	private $subitems = array();


	public function set_id($id) {
		tangra_if_not_int_throw_e($id);

		$this->id = $id;
	}


	public function get_id() {
		return $this->id;
	}


	public function set_menu($menu) {
		tangra_if_not_int_throw_e($menu);

		$this->menu = $menu;
	}


	public function get_menu() {
		return $this->menu;
	}



	public function set_parent($parent) {
		tangra_if_not_int_throw_e($parent);

		$this->parent = $parent;
	}


	public function get_parent() {
		return $this->parent;
	}


	public function set_label($label) {
		$this->label = $label;
	}


	public function get_label() {
		return $this->label;
	}


	public function set_published($published) {
		$this->published = $published ? true : false;
	}


	public function get_published() {
		return $this->published;
	}


	public function set_ordering($ordering) {
		tangra_if_not_int_throw_e($ordering);

		$this->ordering = $ordering;
	}


	public function get_ordering() {
		return $this->ordering;
	}


	public function set_type($type) {
		tangra_if_not_int_throw_e($type);

		$this->type = $type;
	}


	public function get_type() {
		return $this->type;
	}


	public function set_new_window($new_window) {
		tangra_if_not_int_throw_e($new_window);
		if ($new_window < 0 || $new_window > 2) {
			throw new Tangra_Module_Exception('Invalid value for $new_window: '.$new_window);
		}

		$this->new_window = $new_window;
	}


	public function get_new_window() {
		return $this->new_window;
	}


	public function set_subitems($subitems) {
		if (is_array($subitems)) {
			foreach($subitems as $item) {
				$this->add_subitem($item);
			}
		} else {
			throw new Tangra_Module_Exception('$subitems is not an array.');
		}
	}


	public function add_subitem($item) {
		$this->subitems[] = $item;
	}


	public function get_subitems() {
		return $this->subitems;
	}


	public function set_nofollow($nofollow) {
		$this->nofollow = $nofollow ? true : false;
	}


	public function get_nofollow() {
		return $this->nofollow;
	}


	public function set_additional($additional) {
		$this->additional = $additional;
	}


	public function get_additional() {
		return $this->additional;
	}
}